%print a multiplication as matrix
%fid is file id
function print_amult(a, b, p,tm, c, m, n, r, k, fid)
%print a
fprintf(fid,'%s', blanks(n));
disp_bin(a, 0, m, fid);
fprintf(fid,'\n');
%print b
fprintf(fid, '%s', blanks(m));
disp_bin(b, 0, n, fid);
fprintf(fid,'\n');
%print cross
linestr = repmat('-',1,m+n);
fprintf(fid,'%s',linestr);
fprintf(fid,'\n');

%print PP Matrix
pp = zeros(n, m+n);
for i=1:n
    b = b * 2;
    pp(n+1-i,1:i) = blanks(i);
    if b >= 1.0         
        pp(n+1-i,i+1:i+m) = bin2str(a, 0, m);
        b = double(b - 1.0);
    else        
        pp(n+1-i,i+1:i+m) = bin2str(0.0, 0, m);
    end
    if (i < n)
        pp(n+1-i,i+m+1:n+m) = blanks(n-i);
    end
end
for i=1:n
    fprintf(fid,'%s', pp(i,:));
    fprintf(fid,'\n');
end
fprintf(fid,'%s',linestr);
fprintf(fid,'\n');
disp_bin(tm, 0, r+k+1, fid);
fprintf(fid,'\n');
disp_bin(c, 0, r+k+1, fid);
fprintf(fid,'\n');
fprintf(fid,'%s',linestr);
fprintf(fid,'\n');
disp_bin(p, 0, n+m, fid);
end